package cn.tedu.lucky.draw.server.repository;

import cn.tedu.lucky.draw.server.protocol.po.Activity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <T, ID>
 *
 */
@Repository
public interface ActivityRepository extends JpaRepository<Activity,Long> {

    List<Activity> findByName(String name);

    List<Activity> findByIdBetween(Long start,Long end);

    /**
     * 根据活动名称和活动状态来进行升序查询
     */
    List<Activity> findByNameAndStatusOrderBySort(String name,Integer status);

    /**
     * 根据活动状态
     * 根据活动的结束时间
     */

    Page<Activity> findByStatusAndEndTimeBefore(Integer status, LocalDateTime endTime, Pageable pageable);


    List<Activity> findByStatusEquals(Integer status);
}
